package com.wkhyapp.lm.contract;

import com.wkhyapp.lm.base.BasePresenter;
import com.wkhyapp.lm.http.ApiCallback;
import com.wkhyapp.lm.http.net.GoodsListRequest;
import com.wkhyapp.lm.http.net.MemberListRequest;
import com.wkhyapp.lm.http.net.ShopListRequest;
import com.wkhyapp.lm.http.net.SuperResponse;
import com.wkhyapp.lm.http.vo.Banner;
import com.wkhyapp.lm.http.vo.Goods;
import com.wkhyapp.lm.http.vo.Market;
import com.wkhyapp.lm.http.vo.Shop;

/**
 * Created by Administrator on 2021-10-2.
 */

public class JXPresenter extends BasePresenter<JXView> {

    public JXPresenter(JXView jxView) {
        super(jxView);
    }


    public void  getMarket(){
        MemberListRequest request  = new MemberListRequest();
        addSubscription(apiStores.markets(request),new ApiCallback<SuperResponse<Market>>() {
            @Override
            public void onSuccess(SuperResponse<Market> response) {
                mvpView.setMarket(response.getItems());
            }
            @Override
            public void onFailure(String msg) {
                mvpView.setfail(msg);
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });

    }


    public void getData(int id){
        ShopListRequest request = new ShopListRequest();
        request.setPageNo(1);
        request.setDistrictsId(id);
        request.setPageSize(12);
        addSubscription(apiStores.shop(request),new ApiCallback<SuperResponse<Shop>>() {
            @Override
            public void onSuccess(SuperResponse<Shop> response) {
                mvpView.setShop(response.getItems());
            }
            @Override
            public void onFailure(String msg) {
//                mvpView.setfail("");
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });

    }


    public void getShopMore(int pageNo,int id){
        ShopListRequest request = new ShopListRequest();
        request.setPageNo(pageNo);
        request.setDistrictsId(id);
        request.setPageSize(12);
        addSubscription(apiStores.shop(request),new ApiCallback<SuperResponse<Shop>>() {
            @Override
            public void onSuccess(SuperResponse<Shop> response) {
                mvpView.setShopMore(response.getItems());
            }
            @Override
            public void onFailure(String msg) {
//                mvpView.setfail("");
            }

            @Override
            public void onFinish() {
                mvpView.dismissLoad();
            }
        });

    }


}
